import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'


// 第三方vue组件↓
import TreeTable from 'vue-table-with-tree-grid'
Vue.prototype.$http = axios;

//nprogress和css
import nProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 注册vue-quill-editor
import VueQuillEditor from 'vue-quill-editor'
Vue.use(VueQuillEditor)
    // 这里原本有quill.core quill.snow quill.bubble三个css文件，因为后端错误就不做了
import _ from 'lodash'
Vue.use(_)

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.filter('dateFormat', (dateStr, pattern) => {
    var dt = new Date(dateStr);

    var y = dt.getFullYear();
    var m = dt.getMonth();
    var d = dt.getDay();

    if (pattern.toLowerCase() === "yyyy-mm-dd") {
        return `${y}-${m}-${d}`;
    } else {
        var hh = dt.getHours();
        var mm = dt.getMinutes();
        var ss = dt.getSeconds();
        return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
    }
})


// 配置请求根路径
// axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/"
axios.defaults.baseURL = "http://192.168.2.190:8888/api/private/v1/"


// 拦截器
axios.interceptors.request.use(config => {
    console.log(config);
    // 在config里写入authority
    nProgress.start()
    config.headers.Authorization = window.sessionStorage.getItem('token')
    return config
})

axios.interceptors.response.use(config => {
    nProgress.done()
    return config
})
Vue.component('tree-table', TreeTable)

Vue.config.productionTip = false //阻止启动vue那堆生产命令



new Vue({
    router,
    render: h => h(App)
}).$mount('#app')